package com.sc.VenusQueryBeta.adapter.account;

import android.graphics.drawable.Drawable;
import android.support.annotation.Nullable;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseViewHolder;
import com.hengjun.kingstar.sdk.utils.LogUtil;
import com.hengjun.kingstar.sdk.utils.StringUtils;
import com.sc.VenusQueryBeta.R;
import com.sc.VenusQueryBeta.adapter.BaseCompatAdapter;
import com.sc.VenusQueryBeta.model.bean.account.CurrencyBean;

import java.util.List;

/**
 * Created by Administrator on 2018/11/24.
 */

public class CurrencyAdapter extends BaseCompatAdapter<CurrencyBean.DatasBean, BaseViewHolder> {
    private TextView tvcurrency;
    private int anInt;

    public CurrencyAdapter(int layoutResId, @Nullable List<CurrencyBean.DatasBean> data) {
        super(layoutResId, data);
    }

    public CurrencyAdapter(@Nullable List<CurrencyBean.DatasBean> data) {
        super(data);
    }

    public CurrencyAdapter(int layoutResId) {
        super(layoutResId);
    }

    public CurrencyAdapter(int item_currency, List<CurrencyBean.DatasBean> datas, int queryType) {
        super(item_currency, datas);
        anInt = queryType;
    }

    @Override
    protected void convert(BaseViewHolder helper, CurrencyBean.DatasBean item) {

//        helper.setText(R.id.tv_currency,item.getCurrencyName());
        if (anInt == 2) {
            helper.setText(R.id.tv_money, StringUtils.FormatNumber(item.getCommonValue()+"") + mContext.getString(R.string.yuan));
        } else {
            helper.setText(R.id.tv_money, StringUtils.FormatNumber(item.getCommonValue()+"")+ mContext.getString(R.string.wan));
        }

        LogUtil.e("dhsdfasjihfasiofho==="+item.getCommonValue());
        tvcurrency = helper.getView(R.id.tv_currency);
        if (item.getCurrencyName().equals("人民幣")) {
            tvcurrency.setText(item.getCurrencyName());
            Drawable drawable = mContext.getResources().getDrawable(R.drawable.img_china_country);
            drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
            tvcurrency.setCompoundDrawables(drawable, null, null, null);
        } else if (item.getCurrencyName().equals("披索")) {
            tvcurrency.setText(item.getCurrencyName());
            Drawable drawable = mContext.getResources().getDrawable(R.drawable.img_philippines_country);
            drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
            tvcurrency.setCompoundDrawables(drawable, null, null, null);
        } else if (item.getCurrencyName().equals("港幣")) {
            tvcurrency.setText(item.getCurrencyName());
            Drawable drawable = mContext.getResources().getDrawable(R.drawable.img_hk_country);
            drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
            tvcurrency.setCompoundDrawables(drawable, null, null, null);
        } else if (item.getCurrencyName().equals("臺幣")) {
            tvcurrency.setText(item.getCurrencyName());
            Drawable drawable = mContext.getResources().getDrawable(R.drawable.img_tailand);
            drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
            tvcurrency.setCompoundDrawables(drawable, null, null, null);
        }
    }
}
